<template>
  <div class="app-container">
    <div>
      <div>充值注意事项:</div>
      <div>请先通过银行转账的方式向以下的账户进行转账充值</div>
      <div>(严禁使用支付宝转银行卡，微信转账， 非实时到帐)</div>
      <div>[收款银行不定期更换，请注意查看，充值问题联系客服]</div>
    </div>

    <el-form ref="form" :model="form" label-width="100px">

      <el-form-item label="充值金额" prop="money" :rules="[
      { required: true, message: '金额不能为空'},
      { type: 'number', message: '金额必须为数字值'}
    ]">
        <el-input type="money" v-model.number="form.money" style="width:200px"></el-input>
      </el-form-item>

      <el-form-item label="转账人姓名" prop="username" :rules="[{required:true,message:'转账人姓名不能为空'}]">
        <el-input v-model="form.username" style="width: 200px"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit('form')">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

  import { applyRechange } from "@/api/system/rechange";

  export default {
    data() {
      return {
        form: {
          username: '',
          money: ''
        }
      }
    }
    ,
    methods: {
      onSubmit: function (formName) {

        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');

            applyRechange(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                // this.open = false;
                // this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      }
    }
  }
</script>
